/**
 * com.cnhis.his.customer.service.Vbq2Service.java
 */
package com.mbmed.doctor.medadvice.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.mbmed.doctor.commons.mapper.ModelVo;
import com.mbmed.doctor.homepage.bo.Vao2Bo;
import com.mbmed.doctor.homepage.mapper.Vao2;
import com.mbmed.doctor.medadvice.bo.Vbq2Bo;
import com.mbmed.doctor.medadvice.mapper.Vbq2;

/**
 * @file  Vbq2Service.java
 * @author 刘武
 * @version 0.1
 * @todo	Vbq2服务操作接口
 * Copyright(C), 2013-2014
 *		 Shenzhen Coordinates Software Development Co., Ltd.
 * History
 *   	1. Date: 2014-12-24 05:10:40
 *      	Author: 刘武
 *      	Modification: this file was created
 *   	2. ...
 */
@Path("/vbq2")
@Component
public class Vbq2Service {
	
	private static Logger logger = Logger.getLogger(Vbq2.class);
	
	@Autowired
	private Vbq2Bo vbq2Bo;
	
	@Autowired
	private Vao2Bo vao2Bo;
	
	@Context
	Request request;

	
	/**
	 * 查找所有数据库记录
     * @return type : List 返回查询操作所有符合条件的记录的VO对象集合，操作失败返回null
     */
	@GET
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public List<Vbq2> getAll() throws Exception{
        List<Vbq2> list = new ArrayList<Vbq2>();
        return vbq2Bo.getAll();        
    }
	
    /**
     * 查找符合条件的所有数据库记录
     * @param id 与数据库中主键对应的值
     * @return type :  返回查询操作所有符合条件的记录的VO对象，操作失败返回null
     * @throws Exception
     */
	@GET
	@Path("{id}")
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public Vbq2 getVbq2(@PathParam("id") String id) throws Exception{
    	Vbq2 vbq2 = null;
    	return vbq2Bo.get(id);        
    }
	/**
     * 提取最后一次病史记录
     * @param id 与数据库中主键对应的值
     * @return type :  药品：门诊按规格下医嘱，操作失败返回null
     * @throws Exception
     */
	@GET
	@Path("/getadvicevbq")
	@Produces({MediaType.APPLICATION_JSON})
    public ModelVo  getAdviceVbq(
    		@QueryParam("acf01") java.lang.String acf01,
    		@QueryParam("vaa07") java.lang.String vaa07,
    		@QueryParam("vaa01") java.lang.String vaa01
    		) throws Exception{
		ModelVo modelvo = new ModelVo();
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("acf01", acf01);
		map.put("vaa07", vaa07);
		map.put("vaa01", vaa01);
		
		Vbq2 vbq2 = new Vbq2();
		vbq2 = vbq2Bo.getAdviceVbq(map);
		
		List<Vao2> vao2list = new ArrayList<Vao2>();
		vao2list = vao2Bo.getNewDiagnosis(map);
		
		Map<String,Object> remap = new HashMap<String,Object>();
		remap.put("vbq2", vbq2);
		remap.put("vaolist", vao2list);
		modelvo.setMap(remap);
	
    	return modelvo;
	}
	
}
